/**
 * 
 */
package com.tio.live.main.service;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tio.live.main.api.UserServiceIntf;
import com.tio.live.main.model.db02.User;
import com.tio.live.main.model.db02.UserExample;
import com.tio.live.main.model.db02.vo.UserVo;
import com.tio.manager.core.pager.Pageable;
import com.tio.manager.core.utils.ServiceUtils;

/**
 * 用户表
 * 
 * @author: xufei
 */
public class UserServiceLocal
{
	@SuppressWarnings("unused")
	private static Logger log = LoggerFactory.getLogger(UserServiceLocal.class);

	/**
	 * 
	 */
	private UserServiceLocal()
	{

	}

	/**
	 * 
	 * @param userVo
	 * @return
	 */
	public static UserVo add(UserVo userVo)
	{
		 UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		 return userService.add(userVo);
	}

	/**
	 * 删除记录
	 * @param userVo
	 * @return
	 */
	public static int delete(UserVo userVo)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		int deletedCount = userService.delete(userVo);
		return deletedCount;
	}

	/**
	 * 根据主键删除记录
	 * @param id
	 * @return
	 */
	public static int deleteByPrimaryKey(Integer id)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.deleteByPrimaryKey(id);
	}

	/**
	 * 批量删除
	 * @param ids
	 * @return
	 */
	public static int batchDelete(Integer[] ids)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.batchDelete(ids);
	}

	/**
	 * 更新记录(默认情况下，有值没值的字段都会被更新，开发人员需要根据业务调整updateByPrimaryKey的sql语句)
	 * @param userVo
	 * @return
	 */
	public static int updateByPrimaryKey(UserVo userVo)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.updateByPrimaryKey(userVo);
	}

	/**
	 * 只更新有值的字段，没有值的字段不更新
	 * @param userVo
	 * @return
	 */
	public static int updateByPrimaryKeySelective(UserVo userVo)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.updateByPrimaryKeySelective(userVo);
	}

	/**
	 * 根据id选择记录
	 * @param id
	 * @return
	 */
	public static User selectById(Integer id)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.selectById(id);
	}
	
	public static String robot(Integer num) throws Exception
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.createRobot(num);
	}


	/**
	 * 根据Example选择记录集
	 * @param userExample
	 * @return
	 */
	public static List<User> selectByExample(UserExample userExample)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.selectByExample(userExample);
	}

	/**
	 * 根据Example选择一条记录
	 * @param userExample
	 * @return
	 */
	public static User selectOneByExample(UserExample userExample)
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.selectOneByExample(userExample);
	}

	/**
	 * 查询表中所有记录
	 */
	public static List<User> queryAll() throws Exception
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.queryAll();
	}
	
	/**
	 * 
	 * @param pageSize
	 * @param pageIndex
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public static Pageable pageQuery(Integer pageSize, Integer pageIndex, Map<String, Object> params) throws Exception
	{
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.pageQuery(pageSize, pageIndex, params);
	}
	
	public static UserVo findUserByID(int id) throws IOException {
		UserServiceIntf userService = ServiceUtils.getServiceBean(UserServiceIntf.class);
		return userService.findUserByID(id);
	}

	/**
	 * @author tanyaowu
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException
	{

	}
}
